const mysql = require('mysql');
const db = mysql.createPool({
    host: "127.0.0.1",
    port: 3306,
    user: 'root',
    password: 'shootercheng',
    database: "test"
});

const silly = require('silly-datetime');

function currentTime() {
    return silly.format(new Date(), 'YYYY-MM-DD HH:mm:ss');
}

function insertTest() {
    db.querySync('insert into t_todo_list(item_name, create_time) values(?, ?)', 
    ['中文', currentTime()], (err, result) => {
    });
    console.log(result);
}

function selectTest() {
    db.query('select * from t_todo_list where id = ?', ['2'],(err, result) => {
        if (err) {
            console.log(err);
            return;
        }
        for (var index in result) {
            console.log(result[index]);
        }
    });
}

function updateTest() {
    db.query('update t_todo_list set complete_time = ? where id = ?', [currentTime(), 2],
    (err, result) => {
        console.log(result);
    })
}




// insertTest();
// selectTest();
updateTest();